﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Sinacor.OMM.HealthMonitor.Entity.OrderExecutor;

namespace Sinacor.OMM.HealthMonitor.Collector.SharedHealthDataMemoryStorage.OrderExecutor
{
    [Serializable]
    public class OrderExecutorShdms: IDisposable
    {
        
        private static OrderExecutorShdms _orderExecutorShmds;
        private static Mutex mtx = new Mutex();

        private OrderExecutorShdms()
        {

        }

        public static OrderExecutorShdms GetSharedStorage()
        {
            mtx.WaitOne();
            if (_orderExecutorShmds == null)
            {
                _orderExecutorShmds = new OrderExecutorShdms();
            }
            mtx.ReleaseMutex();

            return _orderExecutorShmds;
        }


        private ExecutorData _orderExecutorData;
        public ExecutorData OrderExecutorDataInfo
        {
            get
            {
                if (_orderExecutorData == null)
                    _orderExecutorData = new ExecutorData();

                return _orderExecutorData;
            }
        }

        public void Dispose()
        {
            _orderExecutorShmds = null;
            mtx.Close();
            _orderExecutorData = null;
        }

    }
}
